import React, { useContext } from 'react';
import MyContext from '../util'
// class Sun extends React.Component {
//   static contextType = MyContext
//   render() {
//     console.log(this.context)
//     return <div className=''>
//       <h3>孙子组件</h3>
//     </div>;
//   }
// }

function Sun() {
  let context = useContext(MyContext)
  console.log(context)
  return <div className=''>
    <h3>孙子组件{context.state.q}</h3>
    <button onClick={() => { context.setQ(100) }}>改Q</button>
  </div>;
}
export default Sun